home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8285 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  2.1 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C source text default
98% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 69 6f | 6e 65 77 73 2e 69 6f 6e |Path: io|news.ion|
|00000010| 65 74 2e 6e 65 74 21 75 | 73 65 6e 65 74 0a 46 72 |et.net!u|senet.Fr|
|00000020| 6f 6d 3a 20 74 6d 61 63 | 6b 40 69 6f 6e 65 74 2e |om: tmac|k@ionet.|
|00000030| 6e 65 74 20 28 54 69 6d | 20 4d 63 4b 69 6e 6e 65 |net (Tim| McKinne|
|00000040| 79 29 0a 4e 65 77 73 67 | 72 6f 75 70 73 3a 20 63 |y).Newsg|roups: c|
|00000050| 6f 6d 70 2e 6c 61 6e 67 | 2e 63 2b 2b 0a 53 75 62 |omp.lang|.c++.Sub|
|00000060| 6a 65 63 74 3a 20 4e 65 | 77 62 69 65 20 57 68 65 |ject: Ne|wbie Whe|
|00000070| 72 65 20 61 6d 20 49 20 | 67 6f 69 6e 67 20 77 72 |re am I |going wr|
|00000080| 6f 6e 67 3f 0a 44 61 74 | 65 3a 20 31 36 20 46 65 |ong?.Dat|e: 16 Fe|
|00000090| 62 20 31 39 39 36 20 31 | 34 3a 34 36 3a 31 31 20 |b 1996 1|4:46:11 |
|000000a0| 47 4d 54 0a 4f 72 67 61 | 6e 69 7a 61 74 69 6f 6e |GMT.Orga|nization|
|000000b0| 3a 20 4c 61 6e 67 73 74 | 6f 6e 20 55 6e 69 76 65 |: Langst|on Unive|
|000000c0| 72 73 69 74 79 20 52 65 | 73 65 61 72 63 68 20 61 |rsity Re|search a|
|000000d0| 6e 64 20 45 78 74 65 6e | 73 69 6f 6e 0a 4d 65 73 |nd Exten|sion.Mes|
|000000e0| 73 61 67 65 2d 49 44 3a | 20 3c 34 67 32 35 62 6a |sage-ID:| <4g25bj|
|000000f0| 24 73 61 33 40 69 6f 6e | 65 77 73 2e 69 6f 6e 65 |$sa3@ion|ews.ione|
|00000100| 74 2e 6e 65 74 3e 0a 52 | 65 70 6c 79 2d 54 6f 3a |t.net>.R|eply-To:|
|00000110| 20 74 6d 61 63 6b 40 6c | 75 72 65 73 65 78 74 2e | tmack@l|uresext.|
|00000120| 65 64 75 0a 4e 4e 54 50 | 2d 50 6f 73 74 69 6e 67 |edu.NNTP|-Posting|
|00000130| 2d 48 6f 73 74 3a 20 73 | 74 61 74 69 6f 6e 31 2e |-Host: s|tation1.|
|00000140| 6c 75 72 65 73 65 78 74 | 2e 65 64 75 0a 4d 69 6d |luresext|.edu.Mim|
|00000150| 65 2d 56 65 72 73 69 6f | 6e 3a 20 31 2e 30 0a 43 |e-Versio|n: 1.0.C|
|00000160| 6f 6e 74 65 6e 74 2d 54 | 79 70 65 3a 20 54 65 78 |ontent-T|ype: Tex|
|00000170| 74 2f 50 6c 61 69 6e 3b | 20 63 68 61 72 73 65 74 |t/Plain;| charset|
|00000180| 3d 49 53 4f 2d 38 38 35 | 39 2d 31 0a 58 2d 4e 65 |=ISO-885|9-1.X-Ne|
|00000190| 77 73 72 65 61 64 65 72 | 3a 20 57 69 6e 56 4e 20 |wsreader|: WinVN |
|000001a0| 30 2e 39 39 2e 35 0a 0a | 42 65 6c 6f 77 20 69 73 |0.99.5..|Below is|
|000001b0| 20 61 20 70 72 6f 67 72 | 61 6d 20 77 68 69 63 68 | a progr|am which|
|000001c0| 20 49 20 61 6d 20 74 72 | 79 69 6e 67 20 74 6f 20 | I am tr|ying to |
|000001d0| 77 72 69 74 65 2e 20 49 | 20 66 65 65 6c 20 74 68 |write. I| feel th|
|000001e0| 61 74 20 6d 79 20 70 72 | 6f 62 6c 65 6d 20 0a 69 |at my pr|oblem .i|
|000001f0| 73 20 69 6e 20 74 68 65 | 20 72 65 61 64 28 29 20 |s in the| read() |
|00000200| 66 75 6e 63 74 69 6f 6e | 20 6f 66 20 74 68 65 20 |function| of the |
|00000210| 62 65 6c 6f 77 20 70 72 | 6f 67 72 61 6d 2e 20 49 |below pr|ogram. I|
|00000220| 20 61 6d 20 74 72 79 69 | 6e 67 20 74 6f 20 70 75 | am tryi|ng to pu|
|00000230| 6c 6c 20 0a 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ll .info|rmation |
|00000240| 66 72 6f 6d 20 74 68 65 | 20 73 74 72 75 63 74 75 |from the| structu|
|00000250| 72 65 20 62 79 20 6e 61 | 6d 65 20 72 61 74 68 65 |re by na|me rathe|
|00000260| 72 20 74 68 61 6e 20 62 | 79 20 73 74 72 75 63 74 |r than b|y struct|
|00000270| 75 72 65 20 6f 72 64 65 | 72 2e 20 0a 46 75 72 74 |ure orde|r. .Furt|
|00000280| 68 65 72 20 49 20 66 65 | 65 6c 20 74 68 61 74 20 |her I fe|el that |
|00000290| 74 68 65 20 70 72 6f 62 | 6c 65 6d 20 69 73 20 69 |the prob|lem is i|
|000002a0| 6e 20 74 68 65 20 64 6f | 3a 77 68 69 6c 65 20 70 |n the do|:while p|
|000002b0| 6f 72 74 69 6f 6e 20 6f | 66 20 74 68 65 20 0a 72 |ortion o|f the .r|
|000002c0| 65 61 64 28 29 20 66 75 | 6e 63 74 69 6f 6e 2e 0a |ead() fu|nction..|
|000002d0| 0a 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 69 |..#inclu|de <stdi|
|000002e0| 6f 2e 68 3e 0a 23 69 6e | 63 6c 75 64 65 20 3c 63 |o.h>.#in|clude <c|
|000002f0| 6f 6e 69 6f 2e 68 3e 0a | 23 69 6e 63 6c 75 64 65 |onio.h>.|#include|
|00000300| 20 3c 69 6f 73 74 72 65 | 61 6d 2e 68 3e 0a 23 69 | <iostre|am.h>.#i|
|00000310| 6e 63 6c 75 64 65 20 3c | 73 74 72 69 6e 67 2e 68 |nclude <|string.h|
|00000320| 3e 0a 0a 73 74 72 75 63 | 74 20 63 61 72 7b 0a 09 |>..struc|t car{..|
|00000330| 63 68 61 72 20 6e 61 6d | 65 5b 31 35 5d 3b 0a 09 |char nam|e[15];..|
|00000340| 6c 6f 6e 67 20 6d 69 6c | 65 73 3b 0a 09 7d 3b 0a |long mil|es;..};.|
|00000350| 0a 77 72 69 74 65 28 29 | 3b 0a 72 65 61 64 28 29 |.write()|;.read()|
|00000360| 3b 0a 46 49 4c 45 20 2a | 20 66 50 74 72 3b 0a 0a |;.FILE *| fPtr;..|
|00000370| 6d 61 69 6e 28 29 0a 7b | 0a 63 6c 72 73 63 72 28 |main().{|.clrscr(|
|00000380| 29 3b 0a 69 6e 74 20 63 | 68 6f 3d 30 3b 0a 70 72 |);.int c|ho=0;.pr|
|00000390| 69 6e 74 66 20 28 22 57 | 72 69 74 65 20 64 61 74 |intf ("W|rite dat|
|000003a0| 61 20 28 31 29 20 6f 72 | 20 52 65 61 64 20 64 61 |a (1) or| Read da|
|000003b0| 74 61 20 28 32 29 20 5c | 3f 20 22 29 3b 0a 73 63 |ta (2) \|? ");.sc|
|000003c0| 61 6e 66 28 22 25 6c 64 | 22 2c 20 26 63 68 6f 29 |anf("%ld|", &cho)|
|000003d0| 3b 0a 0a 09 69 66 28 63 | 68 6f 3d 3d 31 29 0a 09 |;...if(c|ho==1)..|
|000003e0| 7b 77 72 69 74 65 28 29 | 3b 7d 0a 0a 09 69 66 28 |{write()|;}...if(|
|000003f0| 63 68 6f 3d 3d 32 29 0a | 09 7b 72 65 61 64 28 29 |cho==2).|.{read()|
|00000400| 3b 7d 0a 0a 72 65 74 75 | 72 6e 20 30 3b 0a 7d 0a |;}..retu|rn 0;.}.|
|00000410| 0a 77 72 69 74 65 28 29 | 0a 7b 0a 63 6c 72 73 63 |.write()|.{.clrsc|
|00000420| 72 28 29 3b 0a 23 20 64 | 65 66 69 6e 65 20 6e 75 |r();.# d|efine nu|
|00000430| 6d 20 31 30 0a 69 6e 74 | 20 63 6f 75 6e 74 3d 31 |m 10.int| count=1|
|00000440| 3b 0a 69 6e 74 20 6e 75 | 6d 62 3d 30 3b 0a 63 6f |;.int nu|mb=0;.co|
|00000450| 75 74 20 3c 3c 20 22 48 | 6f 77 20 6d 61 6e 79 20 |ut << "H|ow many |
|00000460| 63 61 72 73 20 74 6f 20 | 61 64 64 3f 22 3b 0a 63 |cars to |add?";.c|
|00000470| 69 6e 20 3e 3e 20 6e 75 | 6d 62 3b 0a 73 74 72 75 |in >> nu|mb;.stru|
|00000480| 63 74 20 63 61 72 20 63 | 61 72 64 61 74 61 20 5b |ct car c|ardata [|
|00000490| 6e 75 6d 5d 3b 0a 66 50 | 74 72 3d 66 6f 70 65 6e |num];.fP|tr=fopen|
|000004a0| 28 22 63 3a 5c 5c 63 61 | 72 2e 64 61 74 22 2e 22 |("c:\\ca|r.dat"."|
|000004b0| 77 2b 22 29 3b 0a 0a 09 | 64 6f 0a 09 7b 63 6f 75 |w+");...|do..{cou|
|000004c0| 74 20 3c 3c 20 22 4e 61 | 6d 65 20 6f 66 20 63 61 |t << "Na|me of ca|
|000004d0| 72 5c 3f 20 22 3b 0a 09 | 73 63 61 6e 66 28 22 25 |r\? ";..|scanf("%|
|000004e0| 73 22 2c 20 26 63 61 72 | 64 61 74 5b 63 6f 75 6e |s", &car|dat[coun|
|000004f0| 74 5d 2e 6e 61 6d 65 29 | 3b 0a 09 63 6f 75 74 20 |t].name)|;..cout |
|00000500| 3c 3c 20 22 4d 69 6c 61 | 67 65 5c 3f 20 22 3b 0a |<< "Mila|ge\? ";.|
|00000510| 09 73 63 61 6e 66 28 22 | 25 6c 64 22 2c 20 26 63 |.scanf("|%ld", &c|
|00000520| 61 72 64 61 74 5b 63 6f | 75 6e 74 5d 2e 6d 69 6c |ardat[co|unt].mil|
|00000530| 65 73 29 3b 0a 09 63 6f | 75 6e 74 20 2b 2b 3b 0a |es);..co|unt ++;.|
|00000540| 09 7d 77 68 69 6c 65 28 | 63 6f 75 6e 74 20 3c 20 |.}while(|count < |
|00000550| 6e 75 6d 62 2b 31 29 3b | 0a 0a 66 77 72 69 74 65 |numb+1);|..fwrite|
|00000560| 28 63 61 72 64 61 74 2c | 20 73 69 7a 65 6f 66 28 |(cardat,| sizeof(|
|00000570| 63 61 72 64 61 74 29 2c | 20 31 2c 20 66 50 74 72 |cardat),| 1, fPtr|
|00000580| 29 3b 0a 66 63 6c 6f 73 | 65 28 66 50 74 72 29 3b |);.fclos|e(fPtr);|
|00000590| 0a 6d 61 69 6e 28 29 3b | 0a 72 65 74 75 72 6e 20 |.main();|.return |
|000005a0| 30 3b 0a 7d 0a 0a 72 65 | 61 64 28 29 0a 7b 0a 63 |0;.}..re|ad().{.c|
|000005b0| 6c 72 73 63 72 28 29 3b | 0a 63 68 61 72 20 69 63 |lrscr();|.char ic|
|000005c0| 68 5b 31 35 5d 3b 0a 69 | 6e 74 20 77 69 63 68 3d |h[15];.i|nt wich=|
|000005d0| 31 3b 0a 69 6e 74 20 6c | 65 6e 67 74 68 3d 30 3b |1;.int l|ength=0;|
|000005e0| 0a 66 50 74 72 3d 66 6f | 70 65 6e 28 22 63 5c 5c |.fPtr=fo|pen("c\\|
|000005f0| 63 61 72 2e 64 61 74 22 | 2c 20 22 72 2b 22 29 3b |car.dat"|, "r+");|
|00000600| 0a 73 74 72 75 63 74 20 | 63 61 72 20 63 61 72 6e |.struct |car carn|
|00000610| 65 77 5b 31 30 5d 3b 0a | 66 73 65 65 6b 28 66 50 |ew[10];.|fseek(fP|
|00000620| 74 72 2c 20 30 4c 2c 20 | 53 45 45 4b 5f 53 45 54 |tr, 0L, |SEEK_SET|
|00000630| 29 3b 0a 66 72 65 61 64 | 28 63 61 72 6e 65 77 2c |);.fread|(carnew,|
|00000640| 20 73 69 7a 65 6f 66 28 | 63 61 72 6e 65 77 29 20 | sizeof(|carnew) |
|00000650| 31 2c 20 66 50 74 72 29 | 3b 0a 70 72 69 6e 74 66 |1, fPtr)|;.printf|
|00000660| 28 22 57 68 69 63 68 20 | 63 61 72 20 77 6f 75 6c |("Which |car woul|
|00000670| 64 20 79 6f 75 20 6c 69 | 6b 65 20 74 6f 20 6b 6e |d you li|ke to kn|
|00000680| 6f 77 20 61 62 6f 75 74 | 5c 3f 20 22 29 3b 0a 73 |ow about|\? ");.s|
|00000690| 63 61 6e 66 28 22 25 73 | 22 2c 69 63 68 29 3b 0a |canf("%s|",ich);.|
|000006a0| 69 6e 74 20 78 3b 0a 09 | 64 6f 7b 0a 09 78 3d 73 |int x;..|do{..x=s|
|000006b0| 74 72 63 6d 70 28 63 61 | 72 6e 65 77 5b 77 69 63 |trcmp(ca|rnew[wic|
|000006c0| 68 5d 2e 6e 61 6d 65 2c | 69 63 68 29 3b 0a 09 09 |h].name,|ich);...|
|000006d0| 69 66 20 28 78 3d 3d 30 | 29 0a 09 09 7b 0a 09 09 |if (x==0|)...{...|
|000006e0| 70 72 69 6e 74 66 28 22 | 5c 6e 5c 6e 54 68 65 20 |printf("|\n\nThe |
|000006f0| 25 73 20 43 61 72 20 68 | 61 73 20 25 6c 64 20 6d |%s Car h|as %ld m|
|00000700| 69 6c 65 73 22 2c 63 61 | 72 6e 65 77 5b 77 69 63 |iles",ca|rnew[wic|
|00000710| 68 2e 6e 61 6d 65 2c 20 | 0a 63 61 72 6e 65 77 5b |h.name, |.carnew[|
|00000720| 77 69 63 68 5d 2e 6d 69 | 6c 65 73 29 3b 0a 09 09 |wich].mi|les);...|
|00000730| 67 65 74 63 68 28 29 3b | 0a 09 09 66 63 6c 6f 73 |getch();|...fclos|
|00000740| 65 28 66 50 74 72 29 3b | 0a 09 09 6d 61 69 6e 28 |e(fPtr);|...main(|
|00000750| 29 3b 0a 09 09 7d 0a 09 | 77 69 63 68 2b 2b 3b 0a |);...}..|wich++;.|
|00000760| 09 7d 77 68 69 6c 65 28 | 21 66 65 6f 66 28 66 50 |.}while(|!feof(fP|
|00000770| 74 72 29 29 3b 0a 70 72 | 69 6e 74 66 28 22 5c 6e |tr));.pr|intf("\n|
|00000780| 5c 6e 54 68 69 73 20 63 | 61 72 20 69 73 20 6e 6f |\nThis c|ar is no|
|00000790| 74 20 69 6e 20 64 61 74 | 61 62 61 73 65 22 29 3b |t in dat|abase");|
|000007a0| 0a 66 63 6c 6f 73 65 28 | 66 50 74 72 29 3b 0a 6d |.fclose(|fPtr);.m|
|000007b0| 61 69 6e 28 29 3b 0a 72 | 65 74 75 72 6e 20 30 3b |ain();.r|eturn 0;|
|000007c0| 0a 7d 0a 0a 09 54 68 69 | 73 20 70 72 6f 67 72 61 |.}...Thi|s progra|
|000007d0| 6d 20 77 69 6c 6c 20 72 | 65 74 72 69 65 76 65 20 |m will r|etrieve |
|000007e0| 74 68 65 20 66 69 72 73 | 74 20 63 61 72 20 61 6e |the firs|t car an|
|000007f0| 64 20 6d 69 6c 65 73 20 | 74 68 61 74 20 77 61 73 |d miles |that was|
|00000800| 20 70 75 74 20 0a 69 6e | 2c 20 62 75 74 20 77 69 | put .in|, but wi|
|00000810| 6c 6c 20 6e 6f 74 20 72 | 65 74 72 69 65 76 65 20 |ll not r|etrieve |
|00000820| 61 6e 79 20 6f 74 68 65 | 72 20 63 61 72 73 20 65 |any othe|r cars e|
|00000830| 6e 74 65 72 65 64 20 61 | 66 74 65 72 20 74 68 65 |ntered a|fter the|
|00000840| 20 66 69 72 73 74 20 6f | 6e 65 2e 20 0a 54 68 61 | first o|ne. .Tha|
|00000850| 6e 6b 73 20 66 6f 72 20 | 74 68 65 20 68 65 6c 70 |nks for |the help|
|00000860| 0a 54 69 6d 0a 0a | |.Tim.. | |
+--------+-------------------------+-------------------------+--------+--------+